/*
自己选择的路 ,跪着也要走完。朋友们 , 虽然这个世界日益浮躁起来,只
要能够为了当时纯粹的梦想和感动坚持努力下去 , 不管其它人怎么样,我
们也能够保持自己的本色走下去。
To the world , you will be a person , but to a person , you
will be the world .                               ——AKPower
*/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
const int maxn = 3e5 + 10;

stack<int> st;
int d[maxn];
int n;

void add(int x, int val)
{
    while (x <= n)
    {
        d[x] += val;
        x += (x & -x);
    }
}
int get(int x)
{
    int ret = 0;
    while (x)
    {
        ret += d[x];
        x -= (x & -x);
    }
    return ret;
}
int main()
{
    IOS;
    memset(d, 0, sizeof(d));
    cin >> n;
    n *= 2;
    int cnt = 0;
    int need = 1;
    while (n--)
    {
        string s;
        int x;
        cin >> s;
        if (s[0] == 'a')
        {
            cin >> x;
            st.push(x);
            add(x, 1);
            cout << '+' << x << endl;
        }
        else
        {
            if (st.size() == 0)
                ;
            else if (get(st.top() - 1) > 0)
            {
                cout << "delete:" << st.top() << ',' << cnt++ << endl;

                while (st.size())
                    st.pop();
            }
            else
            {
                cout << "now:" << st.top() << endl;
            }

            if (st.size())
                st.pop();
            add(need, -1);
            cout << '-' << need << endl;
            need++;
        }
    }
    cout << cnt << endl;
    getchar();
    getchar();
    return 0;
}
